import Axios from 'axios'
import Qs from 'qs'
export default {
  axios (type) {
    /* axios 配置 */
    Axios.defaults.timeout = 30000
    switch (process.env.NODE_ENV) {
      case 'development':
        Axios.defaults.baseURL = 'http://10.1.120.107'
        break
      case 'testing':
        Axios.defaults.baseURL = 'http://10.1.120.107'
        break
      case 'preprod':
        Axios.defaults.baseURL = 'https://sealsapipre.fangxin.com'
        break
      default:
        Axios.defaults.baseURL = 'https://sealsapi.fangxin.com'
        break
    }
    Axios.defaults.transformRequest = [function (data) {
      data = Qs.stringify(data)
      return data
    }]
    Axios.defaults.headers['x-http-method-override'] = type
    return Axios
  }
}
